<script>
	export default {
		onLaunch: function() {
			//监听路由跳转
			let _this = this;
			uni.addInterceptor('navigateTo', {
				invoke(e) {
					return _this.watchRouter(e);
				}
			})
			uni.addInterceptor('redirectTo', {
				invoke(e) {
					return _this.watchRouter(e);
				}
			})
			uni.addInterceptor('reLaunch', {
				invoke(e) {
					return _this.watchRouter(e);
				}
			})
			uni.addInterceptor('switchTab', {
				invoke(e) {
					return _this.watchRouter(e);
				}
			})
			
		},
		methods: {
			watchRouter(e) {
				let url=e.url;
				const index=url.indexOf('?');
				url=index==-1?url:url.slice(0,index);
				//拦截器监听不到使用navigate标签跳转的页面，可使用api方式跳转。底部tabbar切换的页面，需要在页面onshow中处理
				const auth = [
					'/page_other/job_hunting/home/index','/page_other/live/index',
					//公司信息相关
					/*'/page_other/company/person',
					'/page_other/company/form',*/
					//职位相关
					'/page_other/position/position_manage',
					'/page_other/position/release_position',
				];
				if (!auth.includes(url)) { //如果无需验证
					return true;
				}
				const token = getStorage('login');
				if (token.user) { //如果登录
					return true;
				}
				uni.showModal({
					title: '提示',
					content: '需要先登录！',
					cancelText: '先逛逛',
					confirmText: '去登录',
					success(res) {
						if (res.confirm) {
							uni.reLaunch({
								url: '/pages/mine/index'
							})
						} else {
							uni.navigateBack();
						}
					}
				})
				return false;
			},
		},
		onShow: function() {
			
		},
		onHide: function() {
			
		}
	}
</script>

<style lang="scss">
	@import url("@/static/iconfont/iconfont.css");
	
	view,
	text,
	navigator,
	input,
	picker,
	button,
	image {
		box-sizing: border-box;
	}
	
	.empty {
		text-align: center;
		color: #313131;
		font-size: 28rpx;
		margin: 30rpx 0;
	}
	
	page {
		min-height: calc(100vh - var(--window-bottom) - var(--window-top));
	}
	
	.content {
		width: 100%;
	}
	
	.inputPlaceholder {
		color: $color-placeholder;
		font-weight: normal;
	}
	.btn1{
		background: $color-primary;
		color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 0 auto;
		border-radius: 60rpx;
	}
</style>
